export const banner = {
  data() {
    var checkFile = (rule, value, callback) => {
      if (!this.form.pictureFileId) {
        return callback(new Error(this.$t('formRule.file_rule')));
      } else {
        callback()
      }
    };
    return {
      params: {},
      mode: "add",
      isEdit: false,
      defaultTime: [new Date(2000,1,1,23,59,59)],
      compression: false,
      selectData: [],
      isUploadS3: true,
      scenarioList: [
        {
          name: this.$t('banner_data.usageScenarioH'),
          value: 1
        },
        {
          name: this.$t('banner_data.usageScenarioS'),
          value: 2
        },
        {
          name: this.$t('banner_data.usageScenarioM'),
          value: 3
        }
      ],
			classList: [
				{
					name: this.$t('banner_data.class1'),
					value: 1,
				},
				{
					name: this.$t('banner_data.class2'),
					value: 2,
				},
				{
					name: this.$t('banner_data.class3'),
					value: 3,
				},
				{
					name: this.$t('banner_data.class4'),
					value: 4,
				},
				{
					name: this.$t('banner_data.class5'),
					value: 5,
				},
				{
					name: this.$t('banner_data.class6'),
					value: 6,
				},
				{
					name: this.$t('banner_data.class7'),
					value: 7,
				}
			],
      showUpload: false,
      showProp: false,
      disabled: false,
      accountForm: {},
      uploadForm: {
        movie_id: '',
        start_date: '',
        end_date: '',
        official_site: '',
        information: '',
        fileUrl: null,
        thumbnailUrl: null,
        title: '',
      },
      form: {
        bannerId: '',
        scene: 1,
        bannerName: "",
        bannerSort: 0,
        endDate: "",
        picture: "",
        pictureFileId: "",
        startDate: "",
        status: null,
        type: 1,
        typeId: ""
      },
      rules: {
        "scene": [
          {required: true,message: this.$t('formRule.selectPlaceholder'),trigger: 'change'}
        ],
        "bannerName": [
          {required: true,message: this.$t('formRule.inputPlaceholder'),trigger: 'change'}
        ],
        "bannerSort": [
          {required: true,message: this.$t('formRule.inputPlaceholder'),trigger: 'change'}
        ],
        "endDate": [
          {required: true,message: this.$t('formRule.selectPlaceholder'),trigger: 'change'}
        ],
        "startDate": [
          {required: true, message: this.$t('formRule.selectPlaceholder'), trigger:'change'}
        ],
        "picture": [
          {required: true, validator: checkFile, trigger:'change'}
        ],
        "type": [
          {required: true, message: this.$t('formRule.selectPlaceholder'), trigger:'change'}
        ],
        "typeId": [
          {required: true, message: this.$t('formRule.selectPlaceholder'), trigger:'change'}
        ]

      },
      visible: false,
      isSaveing: false
    }
  },
  watch: {
    // "form.thumbnailId": {
    // 	handler: function (val) {
    //     if(val) {
    //       this.form.picture = this.form.thumbnailUrl;
    //       this.form.pictureFileId = this.form.thumbnailId;
    //     } else {
    //       this.form.picture = "";
    //       this.form.pictureFileId = "";
    //     }
    // 	},
    // 	immediate: true,
    // 	deep: true
    // },
    // "scDialogData.thumbnailUrl": {
    // 	handler: function (val) {
    //     if(val) {
    //       this.form.picture = this.form.thumbnailUrl;
    //       this.form.pictureFileId = this.form.thumbnailId;
    //     } else {
    //       this.form.picture = "";
    //       this.form.pictureFileId = "";
    //     }
    // 	},
    // 	immediate: true,
    // 	deep: true
    // },
  },
  created() {
    
  },
  methods: {
    handleRemovePoster(){
      this.form.picture = "";
      this.form.pictureFileId = "";
      // this.form.thumbnailId = "";
      // this.form.thumbnailUrl = "";
      this.showUpload = true;
    },
    getFile(file){
      this.form.picture = file.tempFile;
    },
    uploadSuccess(res){
      if(!res)return
      this.form.pictureFileId = res;
      this.$message.success(this.$t('banner_data.uploadSuccessText'))
    },
  }
}
